/*
package com.zcy.web;

import com.zcy.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@RestController
@RequestMapping("/zcy")
public class ConsumerController {
    */
/*实现负载循环，轮询*//*

//    @Autowired
//    private DiscoveryClient discoveryClient;// Eureka客户端，可以获取到服务实例信息
    @Autowired
    private RestTemplate restTemplate;
    @GetMapping("/{id}")
    public User getById(@PathVariable("id") Long id) {
//        List<ServiceInstance> instances = discoveryClient.getInstances("USER-PROVIDER");
//        ServiceInstance instance = instances.get(0);
//        String url = "http://"+instance.getHost() + ":" + instance.getPort()+"/user/"+id;
        String url = "http://USER-PROVIDER"+MyConst.URL_USER_BY_ID+id;
        User user = restTemplate.getForObject(url, User.class);
        return user;
    }
}
*/
